From abe0f5cc078b23f47973c341971ebc8ece099b8c Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Fri, 5 Mar 2010 23:21:38 +0000 Subject: [PATCH] * (bug 22738) Allow filtering by action type on query=logevent Needs patrol fixing (but not an api problem) --- RELEASE-NOTES | 1 + includes/api/ApiQueryLogEvents.php | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d33bf3a489..2978fa989c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -42,6 +42,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 22353) Categorised recent changes now works again == API changes in 1.17 == +* (bug 22738) Allow filtering by action type on query=logevent === Languages updated in 1.17 === diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php index aa36b8556a..9df96a2f2f 100644 --- a/includes/api/ApiQueryLogEvents.php +++ b/includes/api/ApiQueryLogEvents.php @@ -48,6 +48,7 @@ class ApiQueryLogEvents extends ApiQueryBase { $this->fld_ids = isset( $prop['ids'] ); $this->fld_title = isset( $prop['title'] ); $this->fld_type = isset( $prop['type'] ); + $this->fld_action = isset ( $prop['action'] ); $this->fld_user = isset( $prop['user'] ); $this->fld_timestamp = isset( $prop['timestamp'] ); $this->fld_comment = isset( $prop['comment'] ); @@ -103,7 +104,10 @@ class ApiQueryLogEvents extends ApiQueryBase { $index['change_tag'] = $wgOldChangeTagsIndex ? 'ct_tag' : 'change_tag_tag_id'; } - if ( !is_null( $params['type'] ) ) { + if ( !is_null( $params['action'] ) ) { + $this->addWhereFld( 'log_action', substr( $params['action'], strrpos( $params['action'], "/" ) + 1 ) ); + } + else if ( !is_null( $params['type'] ) ) { $this->addWhereFld( 'log_type', $params['type'] ); $index['logging'] = 'type_time'; } @@ -232,8 +236,8 @@ class ApiQueryLogEvents extends ApiQueryBase { ApiQueryBase::addTitleInfo( $vals, $title ); } } - - if ( $this->fld_type ) { + + if ( $this->fld_type || $this->fld_action ) { $vals['type'] = $row->log_type; $vals['action'] = $row->log_action; } @@ -292,7 +296,7 @@ class ApiQueryLogEvents extends ApiQueryBase { } public function getAllowedParams() { - global $wgLogTypes; + global $wgLogTypes, $wgLogActions; return array( 'prop' => array( ApiBase::PARAM_ISMULTI => true, @@ -312,6 +316,9 @@ class ApiQueryLogEvents extends ApiQueryBase { 'type' => array( ApiBase::PARAM_TYPE => $wgLogTypes ), + 'action' => array( + ApiBase::PARAM_TYPE => array_keys( $wgLogActions ) + ), 'start' => array( ApiBase::PARAM_TYPE => 'timestamp' ), @@ -342,6 +349,7 @@ class ApiQueryLogEvents extends ApiQueryBase { return array( 'prop' => 'Which properties to get', 'type' => 'Filter log entries to only this type(s)', + 'action' => "Filter log actions to only this type. Overrides {$this->getModulePrefix()}type", 'start' => 'The timestamp to start enumerating from.', 'end' => 'The timestamp to end enumerating.', 'dir' => 'In which direction to enumerate.', -- 2.20.1